package com.xique.door.command.impl;

import com.xique.common.core.web.domain.AjaxResult;
import com.xique.door.bean.domain.AccessDevice;
import com.xique.door.biz.service.IDeviceCommandNewService;
import com.xique.door.command.IDeviceBaseControlService;
import com.xique.door.constant.AccessCommandConstant;
import com.xique.door.device.freeview.service.biz.FreeviewCommandBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: caogq
 * @Date: 2022/3/17 11:35
 * @Description:
 */
@Service
public class DeviceBaseControlServiceImpl implements IDeviceBaseControlService {
    @Autowired
    private FreeviewCommandBizService freeviewCommandBizService;

    @Autowired
    private IDeviceCommandNewService deviceCommandNewService;

    @Override
    public AjaxResult openDoor(AccessDevice accessDevice, Long userId) {
        AjaxResult ajaxResult = AjaxResult.success();
        if (AccessCommandConstant.DeviceType.HQ.equals(accessDevice.getModel())){
            ajaxResult = deviceCommandNewService.openDoor(accessDevice, userId);
        }else if (AccessCommandConstant.DeviceType.FREEVIEW_45.equals(accessDevice.getModel()) ||AccessCommandConstant.DeviceType.FREEVIEW_32.equals(accessDevice.getModel()) ){
            ajaxResult = freeviewCommandBizService.remoteOpenDoor(accessDevice, String.valueOf(userId));
        }
        return ajaxResult;
    }
}
